{{ $memcachedExporterVersion := "0.14.1" }}
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-builder
from: {{ $.Images.BASE_GOLANG_21_BULLSEYE_DEV }}
mount:
  - fromPath: ~/go-pkg-cache
    to: /go/pkg
shell:
  install:
    - export GOPROXY={{ $.GOPROXY }} CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=/usr/bin/musl-gcc
    - git clone --depth 1 --branch v{{ $memcachedExporterVersion }} {{ $.SOURCE_REPO }}/prometheus/memcached_exporter.git /src
    - cd /src
    - make build
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-binaries-artifact
from: {{ $.Images.BASE_ALT_DEV }}
shell:
  install:
    - apt-get install memcached
    - /binary_replace.sh -i "/usr/bin/memcached" -o /relocate
---
image: {{ $.ModuleName }}/{{ $.ImageName }}
fromImage: common/distroless
import:
- artifact: {{ $.ModuleName }}/{{ $.ImageName }}-binaries-artifact
  add: /relocate
  to: /
  before: setup
---
image: {{ $.ModuleName }}/{{ $.ImageName }}-exporter
fromImage: common/distroless
import:
  - artifact: {{ $.ModuleName }}/{{ $.ImageName }}-builder
    add: /src/memcached_exporter
    to: /usr/bin/memcached_exporter
    before: install
docker:
  EXPOSE:
    - "9150"
  ENTRYPOINT:
    - "/usr/bin/memcached_exporter"
